/*
 * \brief  Server-side PCI-session interface
 * \author Norman Feske
 * \date   2008-01-28
 */

/*
 * Copyright (C) 2008-2009 Norman Feske
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _INCLUDE__PCI_SESSION__SERVER_H_
#define _INCLUDE__PCI_SESSION__SERVER_H_

#include <pci_session/pci_session.h>
#include <base/server.h>

namespace Pci {

	class Session_server : public Genode::Server_object, public Session
	{
		public:

			int dispatch(int op, Genode::Ipc_istream &is, Genode::Ipc_ostream &os)
			{

				switch (op) {

				case FIRST_DEVICE:
					{
						Device_capability out_device;

						out_device = first_device();
						os << out_device;
						return 0;
					}

				case NEXT_DEVICE:
					{
						Device_capability out_device, prev_device;

						is >> prev_device;
						out_device = next_device(prev_device);
						os << out_device;
						return 0;
					}

				case RELEASE_DEVICE:
					{
						Device_capability device;
						release_device(device);
						return 0;
					}

				default:

					return -1;
				}
			}
	};
}

#endif /* _INCLUDE__PCI_SESSION__SERVER_H_ */
